-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Board config: timer config simplifications #13871
Conversation
@bkueng - this looks interesting. I do not understand how the association of the IP blocks that are need to support a timer are going to be done. Like where KINETIS_SIM_SCGC6 is the place that FTM0 on a K66 is enabled by what bit is not the same for an FTM3 etc. Where are cascaded clocks handled? (see the IMX rt branch) ISRs should be short as possible. So not calculating (or shifting) at run time is preferred. How will that be done? |
A custom mixer for the crazyflie sounds fine, it's already a weird target. Last I heard it's not even working in master (I don't have one to test). |
e98df6d
to
ebfb18c
Compare
I've done that.
@davids5 I have merged the RT branch and done the changes (not quite finished yet) in bkueng@d363393 and bkueng@b5b6826. The main difference is that the IOMUX PAD and GPIO port + pin are independent. The timer setup and config could also be more generalized (also with cascaded clocks if needed), but I did not look into that.
All ISR routines are unchanged in terms of runtime. If everything looks good I'll continue and update all boards. |
@bkueng - can we have a review of this on the dev call or some other time this week? |
Sure |
@bkueng - Now that I understand the genius in this I have a great appreciation for the work you have done herein. As discussed I will rebase and bring the RT in this week, then you can bring this in on top of it. Thank you! |
ebfb18c
to
e48b618
Compare
Codecov Report
@@ Coverage Diff @@
## master #13871 +/- ##
=========================================
- Coverage 52.98% 52.69% -0.3%
=========================================
Files 625 605 -20
Lines 52991 51256 -1735
=========================================
- Hits 28079 27008 -1071
+ Misses 24912 24248 -664
|
This is now getting ready, I updated all boards. @davids5 once the imxrt is in, I'll rebase once again and update that as well. @PX4/testflights can you test this on all boards that you have? |
a55e2af
to
9fd53a6
Compare
@bkueng - So that I am clear, moving forward the defconfig will not state what HW Timers are enabled if PX4 is driving them as PWM ? I am guessing it was inconsistent? What about UAVCAN, HRT etc? The thing we will need to look out for is a HW timer that has shared usage. Assume A and B a drivers use TIM1. The former MAY manifest it's self as a hardfault (buss fault on not enabled IP block), the more subtle failure will be Wrong (or reset) values in registers. We should leverage all the goodness you have added to get a compilation time HW resource usage/contention map. |
Yes it was inconsistent, and it was also never clear to me when I ported a board if it was needed/harmful/does not matter. HRT also has a check ( |
9fd53a6
to
43a0d4c
Compare
That is true if the driver are not included via defconfig. RCC is it. An example of the RCC stuff is here. is here. https://github.com/PX4/NuttX/blob/px4_firmware_nuttx-8.2/arch/arm/src/stm32/stm32f40xxx_rcc.c#L332-L386 |
Tested on NXP FMUK66 v3Modes Tested
Procedure Notes Log |
The NXP i.MXRT changes (#13678) have merged to master. |
43a0d4c
to
e2f3065
Compare
Updated for imxrt - it is really not SW-developer friendly. |
Tested on PixRacer V4Indoor test flight. Takeoff and landing on Stabilized Log: https://review.px4.io/plot_app?log=b797910e-f15b-433a-9b52-1167a364d0de |
e2f3065
to
e4d7166
Compare
These are not required, and to be consistent we enforce disabling them now.
…nnel indexes IOMUX uses different enumeration from GPIO pin + port, so we cannot use .gpio_out, and add a .gpio_portpin.
4f9071d
to
aa224a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkueng - I have not tested on RT, but that should not stop this from coming in,
Having done another PX4 board port, the most tedious, error-prone and redundant part I find is the timer configuration. This PR aims at improving that, with generality in mind.
Summary
A current timer + channel config looks like this:
Accompanied with several defines in the header in the form
#define GPIO_TIM12_CH2OUT /* PH9 T12C2 FMU8 */ GPIO_TIM12_CH2OUT_2
.The PR reduces all of it to 2 lines, one for the timer definition:
and one for the channel:
Details
io_timers_t
andtimer_io_channels_t
data structures, and removes some fields that are not required or we can easily get at runtime.GPIO_GPIOx_OUTPUT
, and usage of timer_io_channels instead. The data structure stays otherwise the same, but instead of explicitly setting each field,constexpr
methods are used for initialization during build time. This allows to specify only the information that is really required (i.e. timer, channel and pin), while ending up with the same binary.Timer::Timer1
to the NuttX defines (the ones that are currently used).Benefits
Drawbacks
board.h
config, as it requires C++. Overall I still think it's worth exploring a script-based generator (including for the NuttX defconfig).Bugs
While working through this, I found 2 configuration bugs:
first_channel_index
andlast_channel_index
, or remove the fields altogether. Theio_timer_handler
IRQ handler would become slightly slower.@davids5 @dagar